package com.wuli.food.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * MybatisPlus字段自动填充
 * 
 * @author xqq
 */
@Component
public class CustomMetaObjectHandler implements MetaObjectHandler {

	private static final String CREATE_TIME = "createTime";
	private static final String MODIFY_TIME = "updateTime";

//	 private static final String CREATE_USER_ID = "createUserId";
//	 private static final String MODIFY_USER_ID = "modifyUserId";

	@Override
	public void insertFill(MetaObject metaObject) {

		this.setFieldValByName(CREATE_TIME, new Date(), metaObject);
		this.setFieldValByName(MODIFY_TIME, new Date(), metaObject);
	}

	@Override
	public void updateFill(MetaObject metaObject) {

		this.setFieldValByName(MODIFY_TIME, new Date(), metaObject);
	}

}
